{% extends 'layout/basicplus.html' %}

{% block title %}登录{% endblock %}

{% block css %}
    <style>
        .error-msg {
            color: red;
            position: absolute;
            font-size: 13px;
        }
    </style>

{% endblock %}

{% block content %}
    <body class="gray-bg">
    <div class="loginColumns animated fadeInDown">
        <div class="row">
            <div class="col-md-6">
                <h2 class="font-bold">Welcome to IOT System</h2>

                <p style="font-size: 30px;">
                    这里是物联网云系统架构
                </p>

                <p>
                    Based on the Django framework, the bootstrap tool is used to quickly build the browser-side project,
                    and
                    the system functions are gradually improved by modules to facilitate the user to control the
                    equipment.
                </p>

                <p>
                    Use Alibaba Cloud server to build MQTT server, and burn the ESP32 code to connect the device and
                    server.
                </p>

                <p>
                    At the same time, connect the web browser with the server.
                </p>

            </div>
            <div class="col-md-6">
                <div class="ibox-content">
                    <form class="m-t" role="form" method="POST" novalidate>
                        {% csrf_token %}
                        {% for field in form %}
                            {% if field.name == 'code' %}
                                <div class="form-group">
                                    <label for="{{ field.id_for_label }}"><strong
                                            style="font-size: 20px;">{{ field.label }}</strong></label>
                                    <div class="row row-no-gutters">
                                        <div class="col-md-5" style="margin-top: 15px;">
                                            {{ field }}
                                            <span class="error-msg">{{ field.errors.0 }}</span>
                                        </div>

                                        <div class="col-md-5">
                                            <img id="icode" src="/web/image" title='点击刷新验证码'
                                                 style="width:180px; height: 60px;">
                                        </div>
                                    </div>
                                </div>
                            {% elif field.name == 'username' %}
                                <div class="form-group">
                                    <label for="{{ field.id_for_label }}"><strong style="font-size: 20px;">账号</strong></label>
                                    {{ field }}
                                    <span class="error-msg">{{ field.errors.0 }}</span>
                                </div>
                            {% else %}
                                <div class="form-group">
                                    <label for="{{ field.id_for_label }}"><strong
                                            style="font-size: 20px;">{{ field.label }}</strong></label>
                                    {{ field }}
                                    <span class="error-msg">{{ field.errors.0 }}</span>
                                </div>
                            {% endif %}


                        {% endfor %}
                        <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>

                        <a href="/web/resetplus/">    {# ?????????#}
                            <small>忘记密码 ?</small>
                        </a>

                        <p class="text-muted text-center">
                            <small>是否没有账户</small>
                        </p>
                        <a class="btn btn-sm btn-white btn-block" href="/web/registerplus">创建一个用户?</a>
                    </form>
                    <p class="m-t">
                        <small>刘嘉乐-201912902224 毕设 -2023</small>
                    </p>
                </div>
            </div>
        </div>
        <hr/>
        <div class="row">
            <div class="col-md-6">

            </div>
            <div class="col-md-6 text-right">
                <small> 2023 毕设 </small>
            </div>
        </div>
    </div>
    </body>
{% endblock %}

{% block js %}

    <script>
        $(function () {
            bindicode();
            bindichange();


        });

        function bindicode() {
            $('#icode').click(function () {
                var oldSrc = $(this).attr('src');
                $(this).attr('src', oldSrc + "?");
            })
        }

        function bindichange() {
            $('#ichange').click(function () {
                var oldSrc = $('#icode').attr('src');
                $('#icode').attr('src', oldSrc + "?");
            })
        }

    </script>

{% endblock %}